#include <bin.h>
#include <model.h>

#include <memory>
#include <cmath>
#include <iostream>
#include <fstream>

using namespace std;

bin::bin() {
}

bin::~bin() {
}

void
bin::init(model *parent, pngstream *_pngs, int _level, int _offset_x, int _offset_y) {
  this->p = parent;
  this->pngs = _pngs;

  this->row_count = 0;

  this->level = _level;
  this->lcoef = (int) pow(2.0, (double) level);

  this->offset_x = _offset_x / lcoef;
  this->offset_y = _offset_y / lcoef;

  this->chbpp = (pngs->pngheader.bitdepth * pngs->pngheader.channels) / 8;
  this->colsize = p->t_tile_size[0] * lcoef;
  this->rowsize = p->t_tile_size[1] * lcoef;
  this->numtiles_x = pngs->pngheader.width / rowsize;

  this->rows = new unsigned char *[rowsize];
  this->tile = new unsigned char *[rowsize];
}

void
bin::addRow(unsigned char *row) {
}

void
bin::generateTiles() {
}